#include <iostream>
using namespace std;

// 单例模式

// 1、饿汉模式
class singleton
{
private:
    static singleton eton;
    singleton() { cout << "单例模式创建" << endl; }
    ~singleton() {}
    singleton(const singleton &ob) = delete;

public:
    static singleton &getInstance()
    {
        return eton;
    }
};
singleton singleton::eton;

// 懒汉模式

class singleton1
{
private:
    singleton1() { cout << "单例模式创建" << endl; }
    ~singleton1() {}
    singleton1(const singleton1 &ob) = delete;
    singleton1 &operator=(const singleton1 &ob) = delete;

public:
    static singleton1 &getInstance()
    {
        static singleton1 eton;

        return eton;
    }
};
int main()
{
    singleton1::getInstance();
    return 0;
}